package ru.tulupov.scheduledrunner.command.impl;

import ru.tulupov.scheduledrunner.DelayedRunner;
import ru.tulupov.scheduledrunner.InfinitelyRunner;
import ru.tulupov.scheduledrunner.RepeatedRunner;
import ru.tulupov.scheduledrunner.Runner;
import ru.tulupov.scheduledrunner.command.Command;
import ru.tulupov.scheduledrunner.command.CommandAnnotation;
import ru.tulupov.scheduledrunner.command.Context;

@CommandAnnotation(name = "repeat")
public class RepeatedRunCommand extends Command {

	@Override
	public void execute(Context context) {
		if (args.length < 3) {
			throw new RuntimeException();
		}
		Runner runner = new RepeatedRunner(args[0], Long.parseLong(args[1]),Long.parseLong(args[2]));
		context.getThreadPool().execute(runner);
	}

}
